package com.aos.iot.socket.common.handler;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class AbstractHandlerFactor {

    private final Map<String, AbstractHandler> handlerMap;

    public AbstractHandlerFactor(List<AbstractHandler> handlers) {
        this.handlerMap = handlers.stream().collect(Collectors.toMap(AbstractHandler::getProtocolName, AbstractHandler::handler));
    }

    public AbstractHandler getHandler(String protocolName) {
        return handlerMap.get(protocolName);
    }
}
